<?php
namespace plugins\setting\controller;

use cmf\controller\ApiThirdAccessBaseController;
use plugins\setting\model\SettingInstallPackageModel as stpm ;

/**
 * 安装包控制器
 */
class ApiInstallPackageController extends ApiThirdAccessBaseController
{
	/**
	 * 获取包信息
	 */
	public function packageInfo()
	{
	    
	    $param = $this->request->param();
	    if( !isset( $param [ 'type' ] ) || !in_array( $param [ 'type' ] , [ 1,2,3] ) ){
	       return api_json_echo( false , '类型错误' );
	    }
		$info = stpm::order( 'add_time desc' )->where( 'type' , $param [ 'type' ] )->limit( 1 )->find();
		if( isset( $info [ 'download_addr' ] ) ){
			$info [ 'download_addr' ] = empty( $info [ 'download_addr' ] ) ? '' : zy_domain().$info [ 'download_addr' ];
		}
		if( isset( $info [ 'describle' ] ) ){
			$info [ 'describle' ] = str_replace( ["\r\n","\n","\r"] , '[===]', $info [ 'describle' ]  );
			$info [ 'describle' ] = explode( '[===]' , $info [ 'describle' ]  );
		}
		return api_json_echo( true , '成功' , $info );
	}
}